/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package util.jQgrid;

import java.lang.reflect.InvocationTargetException;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;



/**
 *
 * @author CHANWUT
 */
public class JQGridFormatterUtil {

    //private static final Log logger = LogFactory.getLog(JQGridFormatterUtil.class);

  
	 public static String getJSON(int currentPageNo,
	            int limitRecords,
	            int totalRecords,
	            Set objectsToBeAdded,
	            List<String> orderedPropertyNames) {

	       return "aa";
	        //String jsonResult = serializer.exclude("*.class").deepSerialize(json);
	    }
    
    /**
     * override getJSON : Entity
     * @param currentPageNo
     * @param limitRecords
     * @param totalRecords
     * @param rows
     * @return
     * @throws Exception 
     */
    public static String getJSON(int currentPageNo,
            int limitRecords,
            int totalRecords,
            List rows) throws Exception {
    	
        Integer pages = 0;

        if (totalRecords % limitRecords > 0) {
            pages = (totalRecords / limitRecords) + 1;
        } else {
            pages = (totalRecords / limitRecords);
        }

        JQGridContainer container = new JQGridContainer();
        container.setPage(currentPageNo);
        container.setTotal(pages);
        container.setRecords(totalRecords);
        container.setRows(rows);

        return JSONUtil.convertToJSON(container);
    }
    
    public static String getJSON(int currentPageNo,
            int limitRecords,
            int totalRecords,
            List rows,
            Integer transaction) throws Exception {
    	
        Integer pages = 0;

        if (totalRecords % limitRecords > 0) {
            pages = (totalRecords / limitRecords) + 1;
        } else {
            pages = (totalRecords / limitRecords);
        }

        JQGridContainer container = new JQGridContainer();
        container.setPage(currentPageNo);
        container.setTotal(pages);
        container.setRecords(totalRecords);
        container.setRows(rows);
        container.setTransaction(transaction);

        return JSONUtil.convertToJSON(container);
    }
    
    
  
}
